﻿package net.wangit.view.unit.component;

import net.wangit.Row;
import net.wangit.context.ActionContext;
import net.wangit.framework.config.DomainsSettings;
import net.wangit.view.element.ElementComponent;
import net.wangit.view.unit.UnitWriter;
import net.wangit.view.unit.grid.Group;

public class ListUnit extends FormUnit {

	public ListUnit() {
	}

	protected void configure(Row row) {
		if (rowsConfig == null)
			rowsConfig = DomainsSettings.getRowsConfig(domain);
		queryUnitId = row.get("lqu");
		listSize = row.getInt("ls", DomainsSettings.getListSize(domain));
		navigator = row.get("ln", "1");
		showListIndex = !"0".equals(row.get("li"));
		listSelectMode = row.getInt("lsm", 0);
		showListHead = !"0".equals(row.get("lsh"));
		clickMark = !"0".equals(row.get("lmr"));
		moveMark = "1".equals(row.get("gco"));
		rowCombine = row.get("v6");
		sumConfig = row.get("lsc");
	}

	public void addElement2Group(ActionContext ac, Group group,
			ElementComponent ec) {
		group.addElement(ec);
	}

	public UnitWriter getWriter() {
		return new ListUnitWriter();
	}

	public boolean isOperable() {
		return listSelectMode != 0 || getShowMode() != "s";
	}

	public boolean isAddable() {
		return true;
	}
}
